<?php if(!defined('BASEPATH')) exit('No direct script access allowed');

/*
 *	Plugin Name: 菜单显示插件
*/


class Navigation
{

	private  $_CI;
	public function __construct(&$plugin)
	{
		$plugin->registe("PLUGIN::NAVIGATION",$this,'show_menu');
		$this->_CI = & get_instance();
	}

	/*
	 * 显示菜单
	 * @param $formate 输出格式。
	 * @param $type 菜单类型或级别
	 */
	public function show_menu($formate,$type)
	{
		if(empty($formate)) return;

		$menus = $this->_CI->db->select('*')
							->from('pre_menu')
							->where('fid',$type)
							->get()
							->result();
		if(!empty($menus)){
			foreach($menus as $menu){
				$link = site_url('category/'.$menu->menulink);
				$replace = array('{link}','{title}');
				$replaceto = array($link,$menu->menuname);
				echo str_replace($replace,$replaceto,$formate)."\r\n";

			}

		}
	}

}

/* End of file Antispam.php */
/* Location: ./application/st_plugins/Antispam.php */